var h = $(window).height();
$('#main').css('height',h+'px');
function getUrlParam(name){
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]); return null;
}
var types=getUrlParam('type');
var userId = getUrlParam('user_id');
$.ajax({
	type: 'POST',
	dataType : "json",
	contentType: 'application/x-www-form-urlencoded',
	url: "http://fashion.apiyys.com/api/statistics/draw",
	data: {user_id: userId, type: types},
	success:function(data){
		var time = data.result.time;
		// console.log(data.result);
		var price = data.result.price;
		lines(time,price);
	}
})
function lines(time,price){
	var myChart = echarts.init(document.getElementById('main'));
	var data_val = price,
	xAxis_val = time;
	var data_val1 = [0, 0, 0, 0, 0, 0, 0];
	var option = {
		backgroundColor: '#000',
		grid: {
			left: 10,
			top: 70,
			bottom: 20,
			right: 40,
			containLabel: true
		},
		tooltip: {
			show: false,
			backgroundColor: '#384157',
			borderColor: '#384157',
			borderWidth: 1,
			formatter: '{b}:{c}',
			extraCssText: 'box-shadow: 0 0 5px rgba(0, 0, 0, 1)'
		},
		title: {
			text: '最近一周收益趋势',
			left: 'center',
			textStyle: {
				color: '#8f8e94',
				fontSize: 14,
				fontWeight: 'normal'
			}
		},
		xAxis: {
			data: xAxis_val,
			boundaryGap: false,
			axisLabel: {
				textStyle: {
					color: '#5c6076'
				},
				interval: 0
			},
			axisTick: {
				show: false
			}
		},
		yAxis: {
			ayisLine: {
				show: false
			},
			axisLabel: {
				textStyle: {
					color: '#5c6076'
				}
			},
			splitLine: {
				show: true,
				lineStyle: {
					color: '#1f1f1f'
				}
			},
			axisLine: {
				lineStyle: {
					color: '#1f1f1f'
				}
			}
		},

		series: [{
			type: 'line',
			name: '距离',

			animation: true,
			symbol: 'circle',

			hoverAnimation: false,
			data: data_val1,
			itemStyle: {
				normal: {
					color: '#f17a52',
					opacity: 0,
				}
			},
			lineStyle: {
				normal: {
					width: 1,
					color: '#384157',
					opacity: 1
				}
			}
		}, {
			type: 'line',
			name: 'linedemo',
			smooth: true,
			symbolSize: 10,
			animation: false,
			lineWidth: 1.2,
			hoverAnimation: false,
			data: data_val,
			symbol: 'circle',
			lineStyle: {
				normal: {
					width: 1,
					color: "#fff"
				}
			},
			itemStyle: {
				normal: {
					color: '#fff',
					shadowBlur: 40,
					label: {
						show: true,
						position: 'top',
						textStyle: {
							color: '#fff',

						}
					}
				}
			},
			areaStyle: {
				normal: {
					color: '#fff',
					opacity: 0.08
				}
			}

		}]
	};
	myChart.setOption(option);
}
$(document).ready(function() {
	var winH = $(window).height();
	$('#main').height(winH);
});
